<?php
require_once dirname(__FILE__) . '/Migrate.abstract.php';
class WFMigrate30to30 extends AMigrate
{
    /**
     *\brief Desciption
     * This method is main() function of Migration WF30 external beta to WF30 GM build
     * @see AMigrate::execute()
     */
    public function execute(){
        $strPathPidFile = $this->objWidgetPoolFactory->getWFHome() . '/repository/migrate30to30.pid';
        $objMutex = $this->objWidgetPoolFactory->getIOFactory()->getMutex($strPathPidFile);
        //Step1: Start checking is Migrate WF3.0 to WF3.0 process is mutex!
        if(true === $objMutex->isRunning()){
            $msg = __CLASS__ . '::' . __FUNCTION__ . '()=>Another Update process is running!It is not allowed concurrent Migrate WF3.0 to WF3.0 proccess!';
            throw new WFMigrateMigrateException($msg, WFOpt::UPGRADE_WF_FAILED_IS_NOT_MUTEX);
        }
        $msg = '>>>>Step '.$this->getStepNoAccumulate().': Success checking is Migrate WF3.0 to WF3.0 process is mutex!';
        $this->objLogger->info($msg);
        
        $this->doStepCheckFolderWidgetOldExisted();
        
        $this->doStepCheckWFDB();
        
        $this->doStepInitWFDBSchema();
        
        $this->doStepSynWidgetXMLToDB();
        
        $this->doStepSynWidgetComponentXMLToDB();
        
        $this->doStepSynServerListType();
        
        $this->migrateData();
    }
    protected function initColDataMigrate(){
    	$this->colDataMigrate->set('CONTAINER',new WFDataMigrate('CONTAINER', 'container_id'));
        // The order should migrate userdata first, then users, otherwise will cause migrate error
        $this->colDataMigrate->set('userdata',new WFDataMigrate('userdata', 'id'));
        $this->colDataMigrate->set('users',new WFDataMigrate('users', 'id'));
        
        $objDataMigrate = new WFDataMigrate('serverlist', 'id');
        $objDataMigrate->setAssocSkipRecordColNameWithColValue('name', 'localhost');
        $this->colDataMigrate->set('serverlist',$objDataMigrate);
               
        $this->colDataMigrate->set('proxylist',new WFDataMigrate('proxylist', 'id'));
        
        $this->colDataMigrate->set('WP_UPDATE_FILTER',new WFDataMigrate('WP_UPDATE_FILTER', 'filter_id'));
    }
}